<?php

// 9/18/2009: immanuel192 write this action

// this action show your all order in history

if (!defined("EXPONENT")) exit("");
if (!exponent_sessions_loggedIn())
{
	// redirect to homepage
	echo "<script language=javascript>document.location='".URL_BASE."/index.php';</script>";
	die();
}
  global $user;
  global $db;
  
$template = new template('storemodule','_history',$loc);
  exponent_flow_set(SYS_FLOW_PUBLIC);	
  // get all order in history (which is state = 0)
  $ticket=exponent_sessions_getTicketString();
  $get_lang=exponent_lang_loadFile("modules/storemodule/step.php");
  $order=$db->selectObjectsBySql("
       SELECT {$db->prefix}orders.*,
			  {$db->prefix}user.firstname firstname,
			  {$db->prefix}user.lastname lastname
			FROM {$db->prefix}orders INNER JOIN {$db->prefix}user
			ON    {$db->prefix}orders.user_id = {$db->prefix}user.id
		    WHERE user_id = {$user->id}	  AND state = 0");
  foreach ($order as $key=>$value){
	$value->add_date=date($get_lang['date_format'],$value->add_date);
	$value->finish_date=date($get_lang['date_format'],$value->finish_date);
  }
  $perms = storemodule::permissions();
  $template->register_permissions(array_keys($perms),$loc);
  $template->assign("orders",$order);
  $template->output();
?>
